package com.jdwx.opengl.kotlin2;

import com.jdwx.opengl.kotlin.C;
import com.jdwx.opengl.kotlin.D;

import java.util.ArrayList;
import java.util.List;

public class Test {
    static class  Animal{
        public void act(List<? extends Animal> list) {
            for (Animal animal : list) {
                animal.eat(); }
        }
        public void eat() {
            System.out.println("Eating");
        }
    }
    static class Dog extends Animal {}
    static class Dog2 extends Dog {}
    static class Dog3 extends Dog {}
    static class Cat extends Animal {
        public void test(){
            System.out.println("Cat");
        }
    }
    static public void main(String arg[]){
        Animal animal = new Test.Animal();
        List<Animal> list3 = new ArrayList<>();
        list3.add(new Dog());
        list3.add(new Cat());
        animal.act(list3);
        List<Dog> list4 = new ArrayList<>();
        list4.add(new Dog());
        list4.add(new Dog());
        animal.act(list4);
        List<Cat> list5 = new ArrayList<>();
        list5.add(new Cat());
        list5.add(new Cat());
        animal.act(list5);
        Cat b = list5.get(0);

        //xiebian
        ArrayList<? extends Animal> list22=new ArrayList<Dog>();
//        list2.add( new Cat());
//        list2.add( new Animal());
//        Cat jjj = (Cat)list2.get(0);
//        jjj.test();
//

        //逆变
        ArrayList<? super Dog> list = new ArrayList<Animal>();
        list.add( new Dog () );



    }
    class Box  {
        //Compiler error
        //Erasure of method print(List<String>)
        //is the same as another method in type Box
        public void print(List<Integer> integerList) { }
    }
}
